package two.chapter_4.c4_4;

/**
 * 加权有向边
 */
public class DirectedEdge {
    private int v,w;
    private double weight;
    public DirectedEdge(int v,int w,double weight){
        this.v=v;
        this.w=w;
        this.weight=weight;
    }

    /**
     * 边的权重
     */
    public double weight(){
        return weight;
    }

    /**
     * 指出这条边的顶点
     * @return
     */
    public int from(){
        return v;
    }
    /**
     * 这条边指向的顶点
     * @return
     */
    public int to(){
        return w;
    }

    @Override
    public String toString() {
        return String.format("%d->%d %.2f",v,w,weight);
    }
}
